<!-- 播放页头部-->
<template>
  <div class="control-top flex-center-wrap flex-justify-end">
    <div class="control-top-item flex-center-wrap" @click="toGrade">
      <i class="control-top-icon iconfont icon-pingfen"></i>
      <span class="control-top-text">评分</span>
    </div>
    <div class="control-top-item flex-center-wrap" @click="addCollect">
      <i class="control-top-icon iconfont icon-shoucang1"></i>
      <span class="control-top-text">收藏</span>
    </div>
    <div class="control-top-item flex-center-wrap" @click="goToExercise">
      <i class="control-top-icon iconfont icon-tiku"></i>
      <span class="control-top-text">题库</span>
    </div>
  </div>
 
</template>
<script>
import {collectSection} from '@/api/play'
export default {
  data() {
    return {

    }
  },
  computed: {
    // 当前课程视频信息
    courseVdieoInfo() {
      return this.$store.state.play.courseVdieoInfo || {}
    },
    // 播放中的课节
    playingSection() {
      return this.$store.state.play.playingSection || {}
    }
  },
  methods: {
    // 去评价
    toGrade() {
      this.$store.dispatch('play/toggleGradeDialog', true)
    },
    //面包屑跳转页面
    addCollect() {
      let {item_id, course_section_id} = this.playingSection
      let {id} = this.courseVdieoInfo
       let params = {
        course_id: id,
        course_section_id: course_section_id || item_id
      }
      if(!params.course_section_id) {
        return this.$message({
          type: 'error',
          message: '请选择要收藏的课节'
        })
      }
      collectSection(params).then((res) => {
        this.$message({
          type: 'success',
          message: '收藏成功'
        })
      }).catch((e) => {
      })
    },
    //跳转题库
    goToExercise() {

    }
  }
}
</script>
<style scoped>
.control-top {
  height: 54px;
  padding-right: 30px;
}
.control-top-item {
  margin-left: 60px;
  cursor: pointer;
}
.control-top-text {
  color: #8C8C8C;
}
.control-top-item:hover .control-top-text{
  color: #F0F1F2;
}
.control-top-icon {
  margin-right: 5px;
  color: #fff;
  font-size: 24px;
}
</style>